package com.example.inventoryservice.company;


import com.example.inventoryservice.company.strategy.GeneralEnterpriseTaxStrategy;
import com.example.inventoryservice.company.strategy.HighTechEnterpriseTaxStrategy;
import com.example.inventoryservice.company.strategy.SmallEnterpriseTaxStrategy;

import java.util.ArrayList;
import java.util.List;

// 策略工厂 - 负责创建合适的策略实例
public class TaxStrategyFactory {

    private static List<IncomeTaxStrategy> strategies = new ArrayList<>();

    static {
        // 注册所有可用策略
        strategies.add(new SmallEnterpriseTaxStrategy());
        strategies.add(new HighTechEnterpriseTaxStrategy());
        strategies.add(new GeneralEnterpriseTaxStrategy());
    }

    public static IncomeTaxStrategy getStrategy(CompanyFinancialData data) {
        for (IncomeTaxStrategy strategy : strategies) {
            if (strategy.isApplicable(data)) {
                return strategy;
            }
        }
        // 如果没有匹配的策略，使用一般企业策略
        return new GeneralEnterpriseTaxStrategy();
    }
}
